import java.util.Scanner; 
import java.io.*;

public class addrMain { 
	public static void main (String[] args)
	{ 
		Scanner scan = new Scanner (System.in);
		System.out.print ("Enter the PassWord: "); 
		int cheakPw = scan.nextInt();
		int password;
		int exeNum = 0;

		addrManage manage = new addrManage();

		manage.addrLoad();
		password = manage.pwLoad();

		do{
			if(cheakPw == password)
			{
				System.out.println("**************************");
				System.out.println("0. change the password");
				System.out.println("1. Add a new contact");
				System.out.println("2. Display all contact");
				System.out.println("3. View a contact");
				System.out.println("4. Search contacts");
				System.out.println("5. Update a contact");
				System.out.println("6. Delete a contact");
				System.out.println("7. Exit the program");
				System.out.println("**************************");

				System.out.print ("Enter the Number: "); 
				exeNum = scan.nextInt();

				if(exeNum<=7&&exeNum>=0)
				{
					switch(exeNum)
					{
					case 0:
						manage.pwChange(password);
						break;
					case 1:
						manage.addrAdd();
						break;
					case 2:
						manage.addrDisplay();
						break;
					case 3:
						manage.addrView();
						break;
					case 4:
						manage.addrSearch();
						break;
					case 5:
						manage.addrUpdate();
						break;
					case 6:
						manage.addrDelete();
						break;
					case 7:
						manage.addrSave();
						System.out.println ("The End.");
						break;
					}
				}
				else
				{
					System.out.println ("number is Error.");	
				}
			}
			else
			{
				System.out.println ("password is Error.");
				System.out.print ("Enter the PassWord: ");
				cheakPw = scan.nextInt();
			}
		}while(exeNum!=7);
	}
}